package com.heima.jdk8dateDemo;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/***
 *@title DateTImeFormatterDemo
 *@description <TODO description class purpose>
 *@author 12468
 *@version 1.0.0
 *@create 2025-09-10 0:21
 **/
public class DateTImeFormatterDemo {
    public static void main(String[] args) {
        /*
            static DateTimeFormatter ofPattern(格式) 获取格式对象
            String format(时间对象) 按照指定方式格式化
        */

        // 1. 获取时间对象
        ZonedDateTime time = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));

        // 2. 解析/格式化器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss EE a");

        // 3. 格式化
        String result = formatter.format(time);
        System.out.println(result);
    }
}
